home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / Test.Z / Test
Encoding:
Text File  |  1998-10-28  |  4.8 KB  |  199 lines

  1.  
  2.  
  3.  
  4.      TTTTeeeesssstttt((((3333))))          7777////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))           TTTTeeeesssstttt((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.         Test - provides a simple framework for writing test    scripts
  10.  
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.         use    strict;
  14.         use    Test;
  15.         BEGIN { plan tests => 13, todo => [3,4] }
  16.  
  17.         ok(0); # failure
  18.         ok(1); # success
  19.  
  20.         ok(0); # ok, expected failure (see todo list, above)
  21.         ok(1); # surprise success!
  22.  
  23.         ok(0,1);         # failure: '0'    ne '1'
  24.         ok('broke','fixed'); # failure: 'broke' ne 'fixed'
  25.         ok('fixed','fixed'); # success: 'fixed' eq 'fixed'
  26.  
  27.         ok(sub { 1+1 }, 2);     # success: '2'    eq '2'
  28.         ok(sub { 1+1 }, 3);     # failure: '2'    ne '3'
  29.         ok(0, int(rand(2));     # (just kidding! :-)
  30.  
  31.         my @list = (0,0);
  32.         ok @list, 3, "\@list=".join(',',@list);     #extra    diagnostics
  33.         ok 'segmentation fault', '/(?i)success/';     #regex    match
  34.  
  35.         skip($feature_is_missing, ...);    #do platform specific test
  36.  
  37.  
  38.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  39.       Test::Harness    expects    to see particular output when it
  40.       executes tests.  This    module aims to make writing proper
  41.       test scripts just a little bit easier    (and less error    prone
  42.       :-).
  43.  
  44.      TTTTEEEESSSSTTTT TTTTYYYYPPPPEEEESSSS
  45.       +o NORMAL TESTS
  46.           These tests are expected to succeed.  If they don't,
  47.           something's screwed up!
  48.  
  49.       +o SKIPPED TESTS
  50.           Skip tests need a    platform specific feature that might
  51.           or might not be available.  The first argument should
  52.           evaluate to true if the required feature is NOT
  53.           available.  After    the first argument, skip tests work
  54.           exactly the same way as do normal    tests.
  55.  
  56.       +o TODO TESTS
  57.           TODO tests are designed for maintaining an executable
  58.           TODO list.  These    tests are expected NOT to succeed
  59.           (otherwise the feature they test would be    on the new
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      TTTTeeeesssstttt((((3333))))          7777////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))           TTTTeeeesssstttt((((3333))))
  71.  
  72.  
  73.  
  74.           feature list, not    the TODO list).
  75.  
  76.           Packages should NOT be released with successful TODO
  77.           tests.  As soon as a TODO    test starts working, it    should
  78.           be promoted to a normal test and the newly minted
  79.           feature should be    documented in the release notes.
  80.  
  81.      OOOONNNNFFFFAAAAIIIILLLL
  82.         BEGIN { plan test => 4, onfail => sub { warn "CALL 911!" } }
  83.  
  84.       The test failures can    trigger    extra diagnostics at the end
  85.       of the test run.  onfail is passed an    array ref of hash refs
  86.       that describe    each test failure.  Each hash will contain at
  87.       least    the following fields:  package,    repetition, and
  88.       result.  (The    file, line, and    test number are    not included
  89.       because their    correspondance to a particular test is fairly
  90.       weak.)  If the test had an expected value or a diagnostic
  91.       string, these    will also be included.
  92.  
  93.       This optional    feature    might be used simply to    print out the
  94.       version of your package and/or how to    report problems.  It
  95.       might    also be    used to    generate extremely sophisticated
  96.       diagnostics for a particular test failure.  It's not a
  97.       panacea, however.  Core dumps    or other unrecoverable errors
  98.       will prevent the onfail hook from running.  (It is run
  99.       inside an END    block.)     Besides, onfail is probably over-kill
  100.       in the majority of cases.  (Your test    code should be simpler
  101.       than the code    it is testing, yes?)
  102.  
  103.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  104.       the _T_e_s_t::_H_a_r_n_e_s_s manpage and    various    test coverage analysis
  105.       tools.
  106.  
  107.      AAAAUUUUTTTTHHHHOOOORRRR
  108.       Copyright (C)    1998 Joshua Nathaniel Pritikin.     All rights
  109.       reserved.
  110.  
  111.       This package is free software    and is provided    "as is"
  112.       without express or implied warranty.    It may be used,
  113.       redistributed    and/or modified    under the terms    of the Perl
  114.       Artistic License (see
  115.       http://www.perl.com/perl/misc/Artistic.html)
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      TTTTeeeesssstttt((((3333))))          7777////AAAAuuuugggg////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))           TTTTeeeesssstttt((((3333))))
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.      Page 3                        (printed 10/23/98)
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.